﻿/*              Copyright(c) 2008 Dave Sexton              *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;

namespace DaveSexton.DocToMaml
{
	public enum RuleAction
	{
		Remove,
		Replace,
		Convert
	}

	public enum RuleMatchKind
	{
		Attribute,
		TagName,
		ElementId,
		StyleSheetClass
	}

	internal abstract class Rule : IRule
	{
		#region Public Properties
		public string Match
		{
			get
			{
				return match;
			}
		}

		public RuleMatchKind MatchKind
		{
			get
			{
				return matchKind;
			}
		}

		public RuleAction Action
		{
			get
			{
				return action;
			}
		}

		public abstract object Value { get; set; }
		#endregion

		#region Private / Protected
		private readonly string match;
		private readonly RuleMatchKind matchKind;
		private readonly RuleAction action;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="Rule" /> class.
		/// </summary>
		public Rule(string match, RuleMatchKind matchKind, RuleAction action)
		{
			if (string.IsNullOrEmpty(match))
				throw new ArgumentException(Resources.Errors.NullOrEmpty, "match");

			if (!Enum.IsDefined(typeof(RuleMatchKind), matchKind))
				throw new System.ComponentModel.InvalidEnumArgumentException("matchKind", (int) matchKind, typeof(RuleMatchKind));

			if (!Enum.IsDefined(typeof(RuleAction), action))
				throw new System.ComponentModel.InvalidEnumArgumentException("action", (int) action, typeof(RuleAction));

			this.match = match;
			this.matchKind = matchKind;
			this.action = action;
		}
		#endregion

		#region Methods
		public override string ToString()
		{
			return action.ToString() + " " + matchKind.ToString() + " " + match;
		}
		#endregion
	}
}
